import React from "react";
import { RouterContext } from "../context/RouterContext";
import { getMatchItem } from "../utils/getMatchItem";
import { createHashHistory } from "history";
const hashHistory = createHashHistory()
class HashRouter extends React.Component<any, any> {
  getRouterMatchItem(rules) {
    return getMatchItem(rules, location.hash.replace("#", ""));
  }
  
  render() {
    return (
      <RouterContext.Provider
        value={{
          history:hashHistory,
          pathname:()=>{
          
            return location.hash.replace('#','')
          },
          getRouterMatchItem: this.getRouterMatchItem,
        }}
      >
        {this.props.children}
      </RouterContext.Provider>
    );
  }
}
export default HashRouter;
